package day12_集合.homeWork;
import java.util.HashMap;
import java.util.Map;
public class str {
    public static void main(String[] args) {
        String str = "aabbbswacc";
        Map<Character, Integer> counts = new HashMap<>();

        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            counts.put(c, counts.getOrDefault(c, 0) + 1);
        }

        StringBuilder result = new StringBuilder();
        for (Map.Entry<Character, Integer> entry : counts.entrySet()) {
            result.append(entry.getKey()).append(entry.getValue());
        }

        String convertedStr = result.toString();
        System.out.println(convertedStr);
    }
}
